package com.whu.controller;

import com.whu.aircraft.Location;
import com.whu.service.impl.RouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RouteController {


    RouteService routeService;

    String routeId = "";

    public RouteController(RouteService routeService) {
        this.routeService = routeService;
    }

    /*为当前飞行器增加一条航线
    * @airName 飞行器名称
    * @routeName 航线名称
    * */
    @RequestMapping("/addRoute")
    public void addRoute(String airName, String routeName) {
        int airId = routeService.selectAirId(airName);
        int routeCount = routeService.selectRoutesCount(airId);
        routeId = "air_" + airId + "_route_" + (routeCount + 1);
        routeService.createRoute(airId, routeName, routeId);
    }

    /*切换当前条航线
     * @airName 飞行器名称
     * @routeName 航线名称
     * */
    @RequestMapping("/changeRoute")
    public void changeRoute(String airName, String routeName) {
        int airId = routeService.selectAirId(airName);
        routeId = routeService.selectRouteId(airId, routeName);
        System.out.println("end");
    }

    /*给飞行器当前航线增加具体飞行的路径点
    * @routePoints 规划的航线上的所有的点
    * */
    @RequestMapping("/insertRoutePoints")
    public void insertRoutePoints(List<Location> routePoints) {
        System.out.println(routePoints);
        //routeService.insertRoutePoints(routeId, routePoints);
    }

}
